<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        //100 的阶乘
        var num = 3;
        // 求Num的阶乘
        // 1-num之间的所有的数字-都相乘起来
        var res = 1;//记录乘积--初始值设置为1
        for (var i = 1; i <= num; i++) {
            console.log(i);
            // 把循环出来的i 乘到res 上
            res = res * i;
        }
        console.log(res);
    </script>

</body>

</html>